<?php
/**
 * Created on 18 mars 08 by Eric Jeker <eric.jeker@gmail.com>
 * Created on Eclipse 3.2 with PHPEclipse 1.1.8
 * (c) 2007 - 2008 Copyright Eric Jeker <eric.jeker@gmail.com>
**/

use_helper('Date') ;
?>

<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<th>Player</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>Against</th>
		<th>&nbsp;</th>
		<th>Draw</th>
		<th>&nbsp;</th>
		<th>At</th>
	</tr>
<?php foreach ($challenges as $challenge) { 
	if (isset($player) && !$challenge->getIsDraw()) {
		$class = $player->getId() == $challenge->getP1Id() ? 'won' : 'lost' ;
	} else {
		$class = '' ;
	}	?>
	<tr onmouseover="this.className = 'over'" onmouseout="this.className = '<?php echo isset($class) ? $class : '' ?>'" <?php echo isset($class) ? 'class="'.$class.'"' : '' ?>>
	<td><?php echo link_to($challenge->getP1()->getUsername(), 'player/details?player=' . $challenge->getP1Id())?></td>
	<td>(#<?php echo $challenge->getP1Rank() ?>)</td>
	<td>vs</td>
	<td><?php echo link_to($challenge->getP2()->getUsername(), 'player/details?player=' . $challenge->getP2Id()) ?></td>
	<td>(#<?php echo $challenge->getP2Rank() ?>)</td>
	<td class="center"><?php echo $challenge->getIsDraw() == 1 ? image_tag('/web/images/bullet_error.png') : '' ?></td>
	<td><?php echo format_date($challenge->getCreatedAt()) ?></td>
	<td><?php echo link_to(image_tag('/web/images/page_white_magnify.png'), 'challenge/details?challenge=' . $challenge->getId()) ?></td>
	</tr>
<?php } ?>
</table>
